Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash of the report suites override section. #405

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

dompuiu
Copy link
Member

@dompuiu dompuiu commented May 30, 2024

Description

Fix a crash of the report suites override section. Niklas from Scania reported this on the Measure slack channel.

Related Issue

Motivation and Context

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change which does not add functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA or I'm an Adobe employee.
  • I have made any necessary test changes and all tests pass.
  • I have run the Sandbox successfully.
  • I've updated the schema in extension.json or no changes are necessary.
  • My change requires a change to the documentation.

Copy link
Contributor

@jfkhoury jfkhoury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻. Can we add a test for this? And can we proactively look for similar possible issues in this same workflow?

@dompuiu
Copy link
Member Author

dompuiu commented May 30, 2024

👍🏻. Can we add a test for this? And can we proactively look for similar possible issues in this same workflow?

I initially thought about adding a test. But we wouldn't test any workflow. I am not sure if it is worth it so I decided to not do it.

I tested manually all the other fields in the section. Report suites failed, because you can define more than one.

@dompuiu dompuiu force-pushed the fix_report_suite_overrides branch from 6aecee0 to 93fecb3 Compare June 3, 2024 15:54
.max(60, "The Main Ping Interval must be less than 60 seconds.")
.default(10),
}),
adPingInterval: lazy((value) =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know a better way to make a field accept the number or an empty string, please let me know.

@@ -33,7 +33,7 @@ const FormikNumberField = ({ name, width, validate, ...otherProps }) => {
return (
<NumberField
{...otherProps}
value={value}
value={value === "" ? null : value}
Copy link
Member Author

@dompuiu dompuiu Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you provide an empty string to a Spectrum Number Field, it automatically converts that to 0. For keeping it empty, you need to provide a null value.

Formik on the other hand it, will complain if you initialize a field with null and change the field value at a later point. A warning appears in logs where it says a component was changed from uncontrolled to controlled.

That is what I added this change.

@@ -327,6 +327,8 @@ const createExtensionManifest = ({ version }) => {
type: "integer",
},
},
required: ["channel", "playerName"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema was to relaxed. You could have saved an object without channel or playerName. You could have saved also other properties that were not defined.

getInitialInstanceValues: ({ instanceSettings }) => {
if (!instanceSettings.streamingMedia) {
instanceSettings.streamingMedia = getDefaultSettings();
return bridge.getInstanceDefaults();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension configuration was crashing because the instanceSettings was returned. The instance settings was containing keys that could potentially override other bridge method from different sections. We need to return an object that contains just the streamingMedia key.

getInstanceSettings: ({ instanceValues }) => {
const instanceSettings = {};
const { streamingMedia } = instanceValues;

["appVersion", "adPingInterval", "mainPingInterval"].forEach((key) => {
if (!streamingMedia[key]) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I clear the empty values of optional fields. Before, they were saved to the DB.

@jonsnyder jonsnyder merged commit 8e843a3 into main Jun 3, 2024
9 checks passed
@jonsnyder jonsnyder deleted the fix_report_suite_overrides branch June 3, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants